<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户设置-潮聚</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" th:href="@{/css/mui.min.css}"/>
		<link rel="stylesheet" th:href="@{/css/common.css}"/>
		<link rel="stylesheet" th:href="@{/css/icons-extra.css}"/>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">设置</h1>
		</header>
		<div class="mui-content">
			<div class="mui-card">
				<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a id="cj-head" class="mui-navigate-right">头像
						<span class="mui-pull-right head">
							<img class="cj-head-img mui-action-preview" id="head-img1" src="../img/head.jpg">
						</span>
					</a>
				</li>
				<li class="mui-table-view-cell" id="updateUserName">
					<a class="">姓名<span class="mui-pull-right" id="userName">你的名字</span></a>
				</li>
				<li class="mui-table-view-cell" id="updateUserPhone">
					<a class="">手机<span class="mui-pull-right" id="phone"></span></a>
				</li>
				</ul>
			</div>
			
			<div class="mui-card">
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<a class=""  href="/user/updatePassword">修改密码</a>
					</li>
				</ul>
			</div>
			
			<div class="mui-card">
				<ul class="mui-table-view">
				<li class="mui-table-view-cell">
					<a class="">关于潮聚</a>
				</li>
				<li class="mui-table-view-cell">
					<a class="">意见反馈</a>
				</li>
			</ul>
			</div>
		</div>
		<div th:include="common/footer :: nav"></div>
		<script src="/js/mui.min.js"></script>
		<script src="/js/jquery.min.js"></script>
		<script src="/js/common.js"></script>
		<script>
			var name;
			var phone;
			$("#updateUserName").click(function(e){
					var btnArray = ['取消', '确定'];
					mui.prompt('请输入你要修改的名字：', '', '修改姓名 ', btnArray, function(e) {
							if (e.index == 1) {
								updateUserInfo("Phones="+phone+"&name="+e.value);
							} 
					});
			});
			
				$("#updateUserPhone").click(function(e){
					var btnArray = ['取消', '确定'];
					mui.prompt('请输入你要修改的手机号：', '', '修改手机号 ', btnArray, function(e) {
							if (e.index == 1) {
								updateUserInfo("Phones="+e.value+"&name="+name);
							} 
					});
			});
				getUserInfo();
				
				 function getUserInfo(){
	   		 		 $.ajax({
		   		 		url:"/user/userMessage",
		   		 		type:"post",
		   		 		dataType:"json",
		   		 		success:function(response){
		   		 			name = response.result.name;
		   		 			phone = response.result.phone;
		   		 			$("#userName").text(name);
		   		 			$("#phone").text(phone);
		   		 		}
	   			 });
   			 }
   			 
   			 function updateUserInfo(data){
   			 	$.ajax({
		   		 		url:"/user/editdate",
		   		 		type:"get",
		   		 		data:data,
		   		 		dataType:"json",
		   		 		success:function(response){
		   		 				getUserInfo();
		   		 				mui.toast("修改成功");
		   		 		}
	   			 });
   			 }

		</script>
	</body>
</html>